home *** CD-ROM | disk | FTP | other *** search
- package org.apache.xalan.xpath;
-
- import java.io.Serializable;
- import org.apache.xalan.xpath.xml.XSLMessages;
- import org.w3c.dom.DocumentFragment;
- import org.w3c.dom.NodeList;
- import org.w3c.dom.Text;
- import org.xml.sax.SAXException;
-
- public class XObject implements Serializable {
- protected Object m_obj;
- public static final int CLASS_NULL = -1;
- public static final int CLASS_UNKNOWN = 0;
- public static final int CLASS_BOOLEAN = 1;
- public static final int CLASS_NUMBER = 2;
- public static final int CLASS_STRING = 3;
- public static final int CLASS_NODESET = 4;
- public static final int CLASS_RTREEFRAG = 5;
-
- public XObject() {
- }
-
- public XObject(Object var1) {
- this.m_obj = var1;
- }
-
- public int getType() {
- return 0;
- }
-
- private String getTypeString() {
- return "#UNKNOWN";
- }
-
- public double num() throws SAXException {
- this.error(18, new Object[]{this.getTypeString()});
- return (double)0.0F;
- }
-
- public boolean bool() throws SAXException {
- this.error(18, new Object[]{this.getTypeString()});
- return false;
- }
-
- public String str() {
- return this.m_obj.toString();
- }
-
- public String toString() {
- return this.str();
- }
-
- public DocumentFragment rtree(XPathSupport var1) {
- DocumentFragment var2 = this.rtree();
- if (var2 == null) {
- var2 = var1.getDOMFactory().createDocumentFragment();
- Text var3 = var1.getDOMFactory().createTextNode(this.str());
- var2.appendChild(var3);
- }
-
- return var2;
- }
-
- public DocumentFragment rtree() {
- return null;
- }
-
- public Object object() {
- return this.m_obj;
- }
-
- public NodeList nodeset() throws SAXException {
- this.error(19, new Object[]{this.getTypeString()});
- return null;
- }
-
- public MutableNodeList mutableNodeset() throws SAXException {
- this.error(20, new Object[]{this.getTypeString()});
- return (MutableNodeList)this.m_obj;
- }
-
- public Object castToType(int var1, XPathSupport var2) throws SAXException {
- Object var3;
- switch (var1) {
- case 0:
- var3 = this.m_obj;
- break;
- case 1:
- var3 = new Boolean(this.bool());
- break;
- case 2:
- var3 = new Double(this.num());
- break;
- case 3:
- var3 = this.str();
- break;
- case 4:
- var3 = this.nodeset();
- break;
- case 5:
- var3 = this.rtree(var2);
- break;
- default:
- this.error(21, new Object[]{this.getTypeString(), Integer.toString(var1)});
- var3 = null;
- }
-
- return var3;
- }
-
- public boolean lessThan(XObject var1) throws SAXException {
- if (var1.getType() == 4) {
- return var1.greaterThan(this);
- } else {
- return this.num() < var1.num();
- }
- }
-
- public boolean lessThanOrEqual(XObject var1) throws SAXException {
- if (var1.getType() == 4) {
- return var1.greaterThanOrEqual(this);
- } else {
- return this.num() <= var1.num();
- }
- }
-
- public boolean greaterThan(XObject var1) throws SAXException {
- if (var1.getType() == 4) {
- return var1.lessThan(this);
- } else {
- return this.num() > var1.num();
- }
- }
-
- public boolean greaterThanOrEqual(XObject var1) throws SAXException {
- if (var1.getType() == 4) {
- return var1.lessThanOrEqual(this);
- } else {
- return this.num() >= var1.num();
- }
- }
-
- public boolean equals(XObject var1) throws SAXException {
- return var1.getType() == 4 ? var1.equals(this) : this.m_obj.equals(var1.m_obj);
- }
-
- public boolean notEquals(XObject var1) throws SAXException {
- if (var1.getType() == 4) {
- return var1.notEquals(this);
- } else {
- return !this.equals(var1);
- }
- }
-
- protected void error(int var1) throws SAXException {
- this.error(var1, (Object[])null);
- }
-
- protected void error(int var1, Object[] var2) throws SAXException {
- String var3 = XSLMessages.createXPATHMessage(var1, var2);
- throw new XPathException(var3);
- }
- }
-